import Vue from 'vue'
import Router from 'vue-router'
/* Layout */
import Layout from '@/layout'

Vue.use(Router);

/**
 *注意：子菜单仅在路由子项时显示。长度>=1

 *hidden:true如果设置为true，项目将不会显示在侧边栏中（默认为false）

 *alwaysShow:true如果设置为true，将始终显示根菜单

 *如果不设置alwaysShow，当项目有多个子路由时，

 *它将变为嵌套模式，否则不显示根菜单

 *redirect:noRedirect如果设置为noRedirect，则面包屑中不会重定向

 *name：'router-name'＜keep-alive＞使用的名称（必须设置！！！）

 角色：['admin'，'editor']控制页面角色（可以设置多个角色）

 title：“title”显示在侧边栏和面包屑中的名称（推荐集）

 icon:“svg名称”/“l-icon-x”图标显示在侧边栏中

 breadcrumb：false如果设置为false，则该项将隐藏在breadcrump中（默认值为true）

 activeMenu:'/example/list'如果设置了路径，侧边栏将突出显示您设置的路径 */

/**
 * constantRoutes
 * 没有权限要求所有角色都可以访问
 */

export const constantRoutes = [
  {
    path: '/',
    name: 'index',
    hidden:true,
    component: () => import('@/views/index/index'),
    meta: {
      title: '首页',
      isLogin: false, //不需要登录
      header:true,//不需要头部
      footer:true,
      base: '/' + process.env.VUE_APP_WEB_NAME // 设置基准路径为 /trainWeb
    }
  },
  {
    path: '/index',
    name: 'index',
    hidden:true,
    component: () => import('@/views/index/index'),
    meta: {
      title: '首页',
      isLogin: false, //不需要登录
      header:true,//不需要头部
      footer:true,
      base: '/' + process.env.VUE_APP_WEB_NAME // 设置基准路径为 /trainWeb
    }
  },
  {
    path: '/login',
    name: 'login',
    hidden:true,
    component: () => import('@/views/login/index'),
    meta: {
      title: '登录',
      isLogin: false, //不需要登录
      header:false,//不需要头部
      footer:false,
      base: '/' + process.env.VUE_APP_WEB_NAME // 设置基准路径为 /trainWeb
    }
  },


  {
    path: '/training-course-list',
    name: 'training-course-list',
    hidden:true,
    component: () => import('@/views/training-course-list/index'),
    meta: {
      title: '选课中心',
      isLogin: true, //不需要登录
      header:true,//不需要头部
      footer:true,
    }
  },
  {
    path: '/course-list',
    name: 'course-list',
    hidden: true,
    component: () => import('@/views/course-list/index'),
    meta: {
      title: '课程中心',
      isLogin: true, //不需要登录
      header:true,//不需要头部
      footer:true,
    }
  },
  {
    path: '/studyspace',
    name: 'studyspace',
    hidden:false,
    component: () => import('@/views/studyspace/index'),
    meta: {
      title: '学习中心',
      isLogin: true, //不需要登录
      header:true,//不需要头部
      footer:true,
    },
    children:[
      {
        path: '/studyspace/my-trainclass',
        component: () => import('@/views/studyspace/my-trainclass'),
        name: 'my-trainclass',
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的培训班',
          parent:"studyspace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-required-course',
        component: () => import('@/views/studyspace/my-required-course'),
        name: 'my-required-course',
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的课程',
          parent:"studyspace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-history-course',
        component: () => import('@/views/studyspace/my-history-course'),
        name: 'my-history-course',
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '历史课程',
          parent:"studyspace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-exam',
        name: 'my-exam',
        component: () => import('@/views/studyspace/my-exam'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '在线考试',
          parent:"studyspace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-notice',
        name: 'my-notice',
        component: () => import('@/views/studyspace/my-notice'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的消息',
          parent:"studyspace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-order',
        name: 'my-order',
        component: () => import('@/views/studyspace/my-order'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的订单',
          parent:"studyspace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-cart',
        name: 'my-cart',
        component: () => import('@/views/studyspace/my-cart'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的购物车',
          parent:"studyspace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-certificate',
        name: 'my-certificate',
        component: () => import('@/views/studyspace/my-certificate'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的证书',
          parent:"studyspace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-record',
        name: 'my-record',
        component: () => import('@/views/studyspace/my-record'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '培训档案',
          parent:"studyspace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-order-detail',
        name: 'my-order-detail',
        component: () => import('@/views/studyspace/my-order-detail'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的订单详情',
          parent:"studyspace/my-trainclass"
        }
      },
    ],
    default: '/studyspace/my-trainclass',
  },
  {
    path: '/orderSpace',
    name: 'orderSpace',
    hidden:true,
    component: () => import('@/views/studyspace/index'),
    meta: {
      title: '订单中心',
      isLogin: true, //不需要登录
      header:true,//不需要头部
      footer:true,
    },
    children:[
      {
        path: '/orderSpace/my-trainclass',
        component: () => import('@/views/studyspace/my-trainclass'),
        name: 'my-trainclass',
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的培训班',
          parent:"orderSpace/my-trainclass"
        }
      },
      {
        path: '/orderSpace/my-required-course',
        component: () => import('@/views/studyspace/my-required-course'),
        name: 'my-required-course',
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的课程',
          parent:"orderSpace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-history-course',
        component: () => import('@/views/studyspace/my-history-course'),
        name: 'my-history-course',
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '历史课程',
          parent:"orderSpace/my-trainclass"
        }
      },
      {
        path: '/orderSpace/my-exam',
        name: 'my-exam',
        component: () => import('@/views/studyspace/my-exam'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '在线考试',
          parent:"orderSpace/my-trainclass"
        }
      },
      {
        path: '/orderSpace/my-notice',
        name: 'my-notice',
        component: () => import('@/views/studyspace/my-notice'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的消息',
          parent:"orderSpace/my-trainclass"
        }
      },
      {
        path: '/orderSpace/my-order',
        name: 'my-order',
        component: () => import('@/views/studyspace/my-order'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的订单',
          parent:"orderSpace/my-trainclass"
        }
      },
      {
        path: '/studyspace/my-cart',
        name: 'my-cart',
        component: () => import('@/views/studyspace/my-cart'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的购物车',
          parent:"orderSpace/my-trainclass"
        }
      },
      {
        path: '/orderSpace/my-certificate',
        name: 'my-certificate',
        component: () => import('@/views/studyspace/my-certificate'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的证书',
          parent:"orderSpace/my-trainclass"
        }
      },
      {
        path: '/orderSpace/my-record',
        name: 'my-record',
        component: () => import('@/views/studyspace/my-record'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '培训档案',
          parent:"orderSpace/my-trainclass"
        }
      },
      {
        path: '/orderSpace/my-order-detail',
        name: 'my-order-detail',
        component: () => import('@/views/studyspace/my-order-detail'),
        meta: {
          isLogin: true, //不需要登录
          header:true,//不需要头部
          footer:true,
          title: '我的订单详情',
          parent:"orderSpace/my-trainclass"
        }
      },
    ],
    default: '/orderSpace/my-order',
  },
  {
    path: '/notice',
    name: 'notice',
    hidden:true,
    component: () => import('@/views/notice/index'),
    meta: {
      title: '通知公告',
      isLogin: false, //不需要登录
      header:true,//不需要头部
      footer:true,
    }
  },
  {
    path: '/officialtrainingAdmin',
    name: 'officialtrainingAdmin',
    hidden:true,
    component: () => import('@/views/notice/index'),
    meta: {
      title: '政策法规',
      isLogin: false, //不需要登录
      header:true,//不需要头部
      footer:true,
    }
  },
  {
    path: '/notice/detail',
    hidden: true,
    name: 'notice-detail',
    component: () => import('@/views/notice/notice-detail'),
    meta: {
      title: '通知公告详情',
      isLogin: false, //不需要登录
      header:true,//不需要头部
      footer:true,
    }
  },
  {
    path: '/help-center',
    name: 'help-center',
    hidden:true,
    component: () => import('@/views/help-center/index'),
    meta: {
      title: '帮助中心',
      isLogin: false, //不需要登录
      header:true,//不需要头部
      footer:true,
    }
  },
  {
    path: '/training-detail',
    name: 'training-detail',
    component: () => import('@/views/training-detail/index'),
    meta: {
      title: '我的培训班详情',
      isLogin: true, //不需要登录
      header:true,//不需要头部
      footer:true,
    },
    hidden: true,
  },
  {
    path: '/choose-course',
    name: 'choose-course',
    component: () => import('@/views/choose-course/index'),
    meta: {
      title: '选课',
      isLogin: true, //不需要登录
      header:true,//不需要头部
      footer:true,
    },
    hidden: true,
  },
  {
    path: '/show-course',
    name: 'show-course',
    component: () => import('@/views/show-course/index'),
    meta: {
      title: '课程展示',
      isLogin: true, //不需要登录
      header:true,//不需要头部
      footer:true,
    },
    hidden: true,
  },
  {
    path: '/certificate',
    name: 'certificate',
    hidden: true,
    component: () => import('@/views/certificate/index'),
    meta: {
      title: '证书查询',
      isLogin: false, //不需要登录
      header:true,//不需要头部
      footer:true,
    },
  },
  {
    path: '/resetPwd',
    component:() => import('@/views/resetPwd/index'),
    hidden: true,
    name: 'resetPwd',
    meta: {
      title: '忘记密码',
      isLogin: false, //不需要登录
      header:false,//不需要头部
      footer:true,
    },
  },
  {
    path: '/register',
    component:() => import('@/views/register/index'),
    hidden: true,
    name: 'register',
    meta: {
      title: '注册',
      isLogin: false, //不需要登录
      header:true,//不需要头部
      footer:true,
    },
  },
  {
    path: '/pay/toPay',
    name: 'pay/toPay',
    component: () => import('@/views/pay/index'),
    meta: {
      title: '订单确认',
      isLogin: true, //不需要登录
      header:true,//不需要头部
      footer:true,
    },
    hidden: true,
  },
  {
    path: '/pay/toPayCourse',
    hidden: true,
    name: 'pay/toPayCourse',
    component: () => import('@/views/pay/pay-course'),
    meta: {
      title: '核对订单信息',
      isLogin: true,
      header:true,
      footer:true,
    },
  },
  {
    path: '/pay/abcPay',
    hidden: true,
    name: 'pay/abcPay',
    component: () => import('@/views/pay/pay-detail'),
    meta: {
      title: '订单详情',
      isLogin: true, //不需要登录
      header:true,//不需要头部
      footer:true,
    },
  },

  {
    path: '/exam',
    component:() => import('@/views/exam/index'),
    hidden: true,
    name: 'exam',
    meta: {
      title: '考试详情',
      isLogin: true, //不需要登录
      header:false,//不需要头部
      footer:false,
    },
  },
  {
    path: '/examAnalysis',
    component:() => import('@/views/exam/examAnalysis'),
    hidden: true,
    name: 'examAnalysis',
    meta: {
      title: '考试解析',
      isLogin: true, //不需要登录
      header:false,//不需要头部
      footer:false,
    },
  },
  {
    path: '/practice',
    component:() => import('@/views/practice/index'),
    hidden: true,
    name: 'practice',
    meta: {
      title: '练习详情',
      isLogin: true, //不需要登录
      header:false,//不需要头部
      footer:false,
    },
  },
  {
    path: '/practiceAnalysis',
    component:() => import('@/views/practice/practiceAnalysis'),
    hidden: true,
    name: 'practiceAnalysis',
    meta: {
      title: '练习解析',
      isLogin: true, //不需要登录
      header:false,//不需要头部
      footer:false,
    },
  },
  {
    path: '/questionnaire',
    component:() => import('@/views/questionnaire/index'),
    hidden: true,
    name: 'questionnaire',
    meta: {
      title: '调查问卷',
      isLogin: true, //不需要登录
      header:false,//不需要头部
      footer:false,
    },
  },
  {
    path: '/questionnaireAnalysis',
    component:() => import('@/views/questionnaire/questionnaireAnalysis'),
    hidden: true,
    name: 'questionnaireAnalysis',
    meta: {
      title: '调查问卷',
      isLogin: true, //不需要登录
      header: false,//不需要头部
      footer: false,
    },
  },
  {
    path: '/studycourseware',
    component:() => import('@/views/courseware-study/index'),
    hidden: true,
    name: 'studycourseware',
    meta: {
      title: '课件学习',
      isLogin: true, //不需要登录
      header:false,//不需要头部
      footer:false,
    },
  },
  {
    path: '/discussion',
    component:() => import('@/views/discussion/index'),
    hidden: true,
    name: 'discussion',
    meta: {
      title: '主题研讨',
      isLogin: true,
      header:false,
      footer:false,
    },
  },
  {
    path: '/course/singleCourseInfo',
    component:() => import('@/views/course-detail/index'),
    hidden: true,
    name: 'course-detail',
    meta: {
      title: '课程详情',
      isLogin: false,
      header:true,
      footer:true,
    },
  },
  {
    path: '/special-info',
    component:() => import('@/views/special-info/index'),
    hidden: true,
    name: 'special-info',
    meta: {
      title: '专题详情',
      isLogin: false,
      header:true,
      footer:true,
    },
  },
  {
    path: '/blind-phone',
    component:() => import('@/views/blind-phone/index'),
    hidden: true,
    name: 'blind-phone',
    meta: {
      title: '绑定手机号',
      isLogin: false,
      header:true,
      footer:true,
    },

  },
  {
    path: '/weak-password',
    component:() => import('@/views/weak-password/index'),
    hidden: true,
    name: 'weak-password',
    meta: {
      title: '弱密码修改',
      isLogin: false,
      header:true,
      footer:true,
    },
  },
  {
    path: '/play',
    component:() => import('@/views/play/index'),
    hidden: true,
    name: 'play',
    meta: {
      title: '直播详情',
      isLogin: false,
      header:false,
      footer:false,
    },
  },
  {
    path: '/playVideo',
    component:() => import('@/views/playVideo/index'),
    hidden: true,
    name: 'playVideo',
    meta: {
      title: '播放详情',
      isLogin: false,
      header:false,
      footer:false,
    },
  },
  {
    path: '/404',
    hidden: true,
    component: () => import('@/views/error-page/404'),
    name: 'Page404',
    meta: {
      title: '404',
      isLogin: false,
      noCache: true
    }
  },
  {
    path: '/401',
    hidden: true,
    component: () => import('@/views/error-page/401'),
    name: 'Page401',
    meta: {
      title: '401',
      noCache: true ,
      isLogin: false,
    }
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  },
]
/**
 * asyncRoutes
 *需要根据用户角色动态加载的路由
 */
export const asyncRoutes = []
const createRouter = () => new Router({
  mode: 'history', // require service support
  scrollBehavior: () => ({y: 0}),
  routes: constantRoutes
});

const router = createRouter();
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
